//
//  QSShareCustomViewCell.m
//  ZengLongSeSha
//
//  Created by apple on 2017/7/11.
//  Copyright © 2017年 Song. All rights reserved.
//

#import "QSShareCustomViewCell.h"

#import "QSButton.h"

@interface QSShareCustomViewCell()
@property (nonatomic, weak) QSButton *myBtn;
@end

@implementation QSShareCustomViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setSelected:(BOOL)selected
{
    if (selected) {
        self.contentView.backgroundColor = [UIColor lightGrayColor];
    } else {
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
}

/**
 *  设置界面
 */
- (void)setupUI
{
    QSButton *btn = [[QSButton alloc] init];
    btn.enabled = NO;
    btn.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled];
    [self.contentView addSubview:btn];
    self.myBtn = btn;
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.mas_equalTo(self.contentView).offset(0);
    }];
}

#pragma mark - set
- (void)setSharePlatformType:(QSSharePlatformType)sharePlatformType
{
    _sharePlatformType = sharePlatformType;
    
    NSString *btnImage = @"";
    NSString *btnTitle = @"";
    switch (sharePlatformType) {
        case QSShareToSina: {
            btnImage = kSinaShareBtnImageName;
            btnTitle = kSinaShareBtnTitle;
        }
            break;
            
        case QSShareToQQ: {
            btnImage = kQQShareBtnImageName;
            btnTitle = kQQShareBtnTitle;
        }
            break;
            
        case QSShareToQQzone: {
            btnImage = kQQzoneShareBtnImageName;
            btnTitle = kQQzoneShareBtnTitle;
        }
            break;
            
        case QSShareToWechatSession: {
            btnImage = kWechatSessionShareBtnImageName;
            btnTitle = kWechatSessionShareBtnTitle;
        }
            break;
            
        case QSShareToWechatTimeline: {
            btnImage = kWechatTimelineShareBtnImageName;
            btnTitle = kWechatTimelineShareBtnTitle;
        }
            break;
            
        default:
            break;
    }
    
    [self.myBtn setImage:[UIImage imageNamed:btnImage] forState:UIControlStateDisabled];
    [self.myBtn setTitle:btnTitle forState:UIControlStateDisabled];
}
@end
